#define _CRT_SECURE_NO_WARNINGS 1

bool isUnivalTree(struct TreeNode* root) {
    if (root == NULL)
    {
        return true;
    }
    if (root->left)
    {
        if (root->left->val != root->val || !isUnivalTree(root->left))
        {
            return false;
        }
    }
    if (root->right)
    {
        if (root->right->val != root->val || !isUnivalTree(root->right))
        {
            return false;
        }
    }
    return true;
}


bool isSameTree(struct TreeNode* p, struct TreeNode* q) {
    if (p == NULL && q == NULL)
    {
        return true;
    }
    else if (p == NULL || q == NULL)
    {
        return false;
    }
    else if (p->val != q->val)
    {
        return false;
    }
    else
    {
        return isSameTree(p->left, q->left) && isSameTree(q->right, p->right);
    }
}